<template>
  <tbody>
    <tr>
      <input type="checkbox" />
      <th>{{ mor.name }}</th>
      <th>{{ mor.price }}</th>
      <th>
        <button @click="BtnDel">-</button>{{ mor.num
        }}<button @click="BtnAdd">+</button>
      </th>
      <th>{{ num }}</th>
      <button @click="del">删除</button>
    </tr>
  </tbody>
</template>

<script>
export default {
  name: 'zi',
  data() {
    return {
      numb: [],
      arr: [],
    }
  },
  props: ['mor', 'list', 'index'],
  methods: {
    BtnDel() {
      this.$bus.$emit('AllDel', this.num)
      if (this.mor.num <= 0) return
      this.mor.num--
    },
    BtnAdd() {
      this.mor.num++
      this.$bus.$emit('AllAdd', this.num)
    },

    del() {
      this.$bus.$emit('tou', this.index, this.num)
    },
  },
  computed: {
    num() {
      return this.mor.num * this.mor.price
    },

    // btn: {
    //   get() {},
    //   set() {
    //     let a = (this.mor.checked = true)

    //     this.numb.push(a)
    //     console.log(this.numb)
    //     if (this.numb.length === this.list.length) {
    //       console.log('dui')
    //     }
    //   },
    // },
  },
  // watch: {
  //   num(newvalue, oldvalue) {
  //     // console.log(newvalue, oldvalue)
  //     this.arr.push(newvalue)
  //     console.log(this.arr)
  //     let num = this.arr.reduce((pev, item) => {
  //       return pev + item
  //     })
  //     this.$bus.$emit('AllNum', num)
  //   },
  // },
}
</script>

<style></style>
